package com.lkj.youmeng.base;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.lkj.youmeng.R;

public class BaseTitleView extends RelativeLayout {
    private ImageView mLeftIv,mLogo,mRightIv;
    private TextView mLeftTv,mTitle,mRightTv;

    public BaseTitleView(Context context) {
        super(context);
    }

    public BaseTitleView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        View view = LayoutInflater.from(context).inflate(R.layout.base_title_layout, this,true);
        mLeftTv = view.findViewById(R.id.base_left_tv);
        mLeftIv = view.findViewById(R.id.base_left_iv);
        mTitle = view.findViewById(R.id.base_title_tv);
        mRightTv = view.findViewById(R.id.base_right_tv);
        mRightIv = view.findViewById(R.id.base_right_iv);
        mLogo = view.findViewById(R.id.base_logo);
    }

    public void setLeftTv(String text,OnClickListener listener){
        mLeftTv.setText(text);
        mLeftTv.setOnClickListener(listener);
    }

    public void setLeftIv(int resid){
        mLeftIv.setImageResource(resid);
    }

    public void setLogoIv(int resid){
        mLogo.setImageResource(resid);
    }

    public void setTitle(String title){
        mTitle.setText(title);
    }

    public void setRightTv(String text,OnClickListener listener){
        mRightTv.setText(text);
        mRightTv.setOnClickListener(listener);
    }

    public void setRightIv(int resid,OnClickListener listener){
        mRightIv.setImageResource(resid);
        mRightIv.setOnClickListener(listener);
    }
}
